{template 'common/header'}
<script>
    $(function(){
        $(".se_remark").blur(function(){
            var se_remark = $(this).val();
            var url = "{php echo $this->createWebUrl('orders',array('op' => 'change_order_goods'))}";
            var order_goods_id = $(this).parent().parent().attr('order_goods_id');
            $.ajax({
                type : "post",
                url : url,
                data : {'se_remark' : se_remark, 'order_goods_id' : order_goods_id},
                success : function(data){
                    if(data == 111){
                        location.reload();
                    }else{
                        alert(data);
                    }
                }
            });
        });
        $(".get").blur(function(){
            var get = $(this).val();
            var url = "{php echo $this->createWebUrl('orders',array('op' => 'change_order_goods'))}";
            var order_goods_id = $(this).parent().parent().attr('order_goods_id');
            $.ajax({
                type : "post",
                url : url,
                data : {'get' : get, 'order_goods_id' : order_goods_id},
                success : function(data){
                    if(data == 111){
                        location.reload();
                    }else{
                        alert(data);
                    }
                }
            });
        });
        $(".had_get").blur(function(){
            var get = $(this).val();
            var url = "{php echo $this->createWebUrl('orders',array('op' => 'change_order_goods'))}";
            var order_goods_id = $(this).parent().parent().attr('order_goods_id');
            $.ajax({
                type : "post",
                url : url,
                data : {'had_gen_get' : get, 'order_goods_id' : order_goods_id},
                success : function(data){
                    if(data == 111){
                        location.reload();
                    }else{
                        alert(data);
                    }
                }
            });
        });
        $(".export-data").click(function(){
            var se_member = $("#se_member").val();
            var order_member = $("#order_member").val();
            var se_goods = $("#se_goods").val();
            var type = $("#type").val();
            var order_day = $("#order_day").val();
            var se_day = $("#se_day").val();
            var se_man = $("#se_man").val();
            var se_remark = $("#se_remark").val();
            location.href="{php echo $this->createWebUrl('settlement',array('op' => 'export_collection'))}&se_member="+se_member+"&order_member="+order_member+"&se_goods="+se_goods+"&type="+type+"&order_day="+order_day+"&se_day="+se_day+"&se_man="+se_man+"&se_remark="+se_remark;
        });
        $(".find").click(function(){
            var se_member = $("#se_member").val();
            var order_member = $("#order_member").val();
            var se_goods = $("#se_goods").val();
            var type = $("#type").val();
            var order_day = $("#order_day").val();
            var se_day = $("#se_day").val();
            var se_man = $("#se_man").val();
            var se_remark = $("#se_remark").val();
            location.href="{php echo $this->createWebUrl('settlement',array('op' => 'collection'))}&se_member="+se_member+"&order_member="+order_member+"&se_goods="+se_goods+"&type="+type+"&order_day="+order_day+"&se_day="+se_day+"&se_man="+se_man+"&se_remark="+se_remark;
        });
    });
</script>
<ul class="nav nav-tabs">
    <li ><a href="{php echo $this->createWebUrl('settlement', array('op'=>'index'))}">代付款结算单</a></li>
    <li class="active" ><a href="{php echo $this->createWebUrl('settlement', array('op'=>'collection'))}">代收款结算单</a></li>
</ul>
<div class="main">
    <div class="panel panel-primary">
        <div class="panel-body">
            <div class="panel-body">
                <div class="row">
                    <div class="col-xs-3">
                        <label class="col-xs-12 col-sm-3 col-md-2 control-label">寄件客户</label>
                        <div class="col-sm-9 col-xs-12">
                            <input type="text" id="se_member" class="form-control" value="{$se_member}" />
                        </div>
                    </div>
                    <div class="col-xs-3">
                        <label class="col-xs-12 col-sm-3 col-md-2 control-label">客户</label>
                        <div class="col-sm-9 col-xs-12">
                            <input type="text" id="order_member" class="form-control" value="{$order_member}" />
                        </div>
                    </div>
                    <div class="col-xs-3">
                        <label class="col-xs-12 col-sm-3 col-md-2 control-label">品名</label>
                        <div class="col-sm-9 col-xs-12">
                            <input type="text" id="se_goods" class="form-control" value="{$se_goods}" />
                        </div>
                    </div>
                    <div class="col-xs-3">
                        <label class="col-xs-12 col-sm-3 col-md-2 control-label">状态</label>
                        <div class="col-sm-9 col-xs-12">
                            <select class="form-control" id="type" >
                                <option value="0">所有状态</option>
                                <option value="1" {if $type == 1} selected="selected" {/if}>未结算</option>
                                <option value="2" {if $type == 2} selected="selected" {/if}>已结算</option>
                            </select>
                        </div>
                    </div>
                </div>
                <br />
                <div class="row">
                    <div class="col-xs-3">
                        <label class="col-xs-12 col-sm-3 col-md-2 control-label">订单日期</label>
                        <div class="col-sm-9 col-xs-12">
                            <input type="date" class="form-control" id="order_day" value="{$order_day}" />
                        </div>
                    </div>
                    <div class="col-xs-3">
                        <label class="col-xs-12 col-sm-3 col-md-2 control-label">结算日期</label>
                        <div class="col-sm-9 col-xs-12">
                            <input type="date" class="form-control" id="se_day" value="{$se_day}" />
                        </div>
                    </div>
                    <div class="col-xs-3">
                        <label class="col-xs-12 col-sm-3 col-md-2 control-label">结算人</label>
                        <div class="col-sm-9 col-xs-12">
                            <select class="form-control" id="se_man">
                                <option value="0">请选择结算人</option>
                                {loop $users $user}
                                <option value="{$user['uid']}" {if $user['uid'] == $se_man} selected="selected" {/if}>
                                {$user['username']}
                                </option>
                                {/loop}
                            </select>
                        </div>
                    </div>
                    <div class="col-xs-3">
                        <label class="col-xs-12 col-sm-3 col-md-2 control-label">标注</label>
                        <div class="col-sm-9 col-xs-12">
                            <input type="text" id="se_remark" class="form-control" value="{$se_remark}" />
                        </div>
                    </div>

                </div>
                <br />
                <div class="row">
                    <div class="col-xs-3">
                        <div class="col-sm-9 col-xs-12">
                            <button class="btn btn-default find">搜索</button>
                            <button class="btn btn-default export-data">导出</button>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <table class="table">
        <tr>
            <th>客户</th>
            <th>订单日期</th>
            <th>寄件客户</th>
            <th>品名</th>
            <th>代收款</th>
            <th>已收代收款</th>
            <th>已结算金额</th>
            <th>完成状态</th>
            <th>标注</th>
            <th>结算时间</th>
            <th>结算人</th>
            <th>备注</th>
        </tr>
        {loop $list $l}
        <tr order_goods_id="{$l['id']}">
            <td>{$l['order']['name']}</td>
            <td>{$l['order']['day']}</td>
            <td>{$l['member']['name']}</td>
            <td>{$l['goods']['name']}</td>
            <td>{$l['gen_get']}</td>
            <td>
                <input type="text" value="{$l['had_gen_get']}" class="form-control had_get" style="width:100px;" />

            </td>
            <td><input type="text" value="{$l['had_se_get']}" class="form-control get" style="color:red;width:100px;" /></td>
            <td>
                {if $l['had_se_get'] > 0}
                已结算
                {else}
                未结算
                {/if}
            </td>
            <td>
                <input type="text" class="form-control se_remark" value="{$l['se_remark']}" style="width: 100px;" />
            </td>
            <td>{$l['se_get_day']}</td>
            <td>{$l['se_get_user']}</td>
            <td>{$l['remark']}</td>
        </tr>
        {/loop}
    </table>
    <div>{$pager}</div>
</div>


{template 'common/footer'}